package com.ytf.test.fifth;

/**
 * @author: YTF
 * @date: 2024/9/20 18:58
 * @version: 1.0
 * @description:
 */
public class SimpleEnumUse {
    public static void main(String[] args) {
        Spiciness howHot = Spiciness.MEDIUM;
        System.out.println(howHot);
        /**
         * Output:
         * MEDIUM
         */
    }
}
class EnumOrder {
    public static void main(String[] args) {
        for (Spiciness spiciness : Spiciness.values()) {
            System.out.println(spiciness+", ordinal "+spiciness.ordinal());
        }
        /**
         * Output:
         * NOT, ordinal 0
         * MILD, ordinal 1
         * MEDIUM, ordinal 2
         * HOT, ordinal 3
         * FLAMING, ordinal 4
         */
    }
}
class Burrito{
    Spiciness degree;

    public Burrito(Spiciness degree) {
        this.degree = degree;
    }
    void describe(){
        System.out.print("This burrito is ");
        switch (degree){
            case HOT:
                System.out.println("Not spicy at all");
                break;
            case MILD:
            case MEDIUM:
                System.out.println("a little not");
                break;
            case NOT:
            case FLAMING:
            default:
                System.out.println("maybe too hot");
        }
    }

    public static void main(String[] args) {
        Burrito plain =new Burrito(Spiciness.NOT);
        Burrito greenChile =new Burrito(Spiciness.MEDIUM);
        Burrito jalapeno =new Burrito(Spiciness.HOT);
        plain.describe();
        greenChile.describe();
        jalapeno.describe();

        /**
         * Output:
         * This burrito is maybe too hot
         * This burrito is a little not
         * This burrito is Not spicy at all
         *
         * 总结：
         *  枚举和switch 语句是绝佳的组合
         */
    }
}